package com.link510.aitools.core.domain.message;

import android.content.Intent;

import com.link510.aitools.core.constants.CWMConstans;

import java.io.Serializable;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author cqnews
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public abstract class BaseMessageEvent implements Serializable {

    private static final long serialVersionUID = -7330342265289669824L;
    /**
     * 消息分类
     */
    private String action = "";


    /**
     * 消息状态 -1为常态，0为成功，正常值为错误码
     */
    private int state = -1;

    /**
     * 消息说明
     */
    private String message = "";


    /**
     * 消息正文
     */
    private Object content;


    public BaseMessageEvent(String message) {
        this.message = message;
    }


    public BaseMessageEvent(String action, int state, String message) {
        this.action = action;
        this.state = state;
        this.message = message;
    }


    public static BaseMessageEvent read(Intent intent) {
        return (BaseMessageEvent) intent.getSerializableExtra(CWMConstans.FILTER_MESSAGE_PARAMETER_KEY);
    }

}
